                                                                                
 MODULE mod_chem_spack_fexchem                                                  
                                                                                
   USE mod_chem_spack_rates, ONLY: rates  ! subroutine                          
   IMPLICIT NONE                                                                
   PRIVATE                                                                      
   PUBLIC :: fexchem ! subroutine                                               
 CONTAINS                                                                       
                                                                                
   SUBROUTINE fexchem(y,rk,chem,ngas,ijkbegin,ijkend,maxblock_size,nr)          
                                                                                
!------------------------------------------------------------------------       
!                                                                               
!     -- DESCRIPTION                                                            
!                                                                               
!     This routine computes the chemical production term.                       
!     This routine is automatically generated by SPACK.                         
!     Mechanism: ../Mechanism/LPCE                                              
!     Species: ../Mechanism/ciLPCE                                              
!                                                                               
!------------------------------------------------------------------------       
!                                                                               
!     -- INPUT VARIABLES                                                        
!                                                                               
!     Y: chemical concentrations.                                               
!     RK: kinetic rates.                                                        
!     ZCSOURC: volumic emissions.                                               
!                                                                               
!     -- INPUT/OUTPUT VARIABLES                                                 
!                                                                               
!     -- OUTPUT VARIABLES                                                       
!                                                                               
!     CHEM: array of chemical production terms.                                 
!                                                                               
!------------------------------------------------------------------------       
!                                                                               
!     -- REMARKS                                                                
!                                                                               
!------------------------------------------------------------------------       
!                                                                               
!     -- MODIFICATIONS                                                          
!                                                                               
!------------------------------------------------------------------------       
!                                                                               
!     -- AUTHOR(S)                                                              
!                                                                               
!     SPACK.                                                                    
!                                                                               
!------------------------------------------------------------------------       
                                                                                
       IMPLICIT NONE                                                            
                                                                                
                                                                                
      INTEGER  	, INTENT(IN)  :: ngas                                           
      INTEGER  	, INTENT(IN)  :: ijkbegin		                                     
      INTEGER  	, INTENT(IN)  :: ijkend 		                                      
      INTEGER  	, INTENT(IN)  :: maxblock_size		                                
      INTEGER  	, INTENT(IN)  :: nr		  	                                        
      DOUBLE PRECISION , INTENT(IN)  :: rk(maxblock_size,nr)	                   
      DOUBLE PRECISION , INTENT(IN)  :: y(maxblock_size,ngas)                   
      DOUBLE PRECISION , INTENT(OUT) :: chem(maxblock_size,NGAS)                
      DOUBLE PRECISION :: w(maxblock_size,nr)			                                
      INTEGER ::  ijk						                                                     
                                                                                
                                                                                
!     Compute reaction rates.                                                   
                                                                                
      call rates(rk,y,w,ngas,ijkbegin,ijkend,maxblock_size,nr)                  
                                                                                
!     Chemical production terms.                                                
                                                                                
                                                                                
      DO ijk=ijkbegin,ijkend                                                    
      chem(ijk,  1) = - w(ijk,  1) &
          - w(ijk,  2) &
          + w(ijk,  3)
      chem(ijk,  2) = - w(ijk,  1)
      chem(ijk,  3) = + w(ijk,  1) &
          - w(ijk,  2) &
          + w(ijk,  3)
      chem(ijk,  4) = + w(ijk,  2) &
          - w(ijk,  3)
      END DO   
                                                                                
!     Volumic source terms.                                                     
                                                                                
                                                                                
   END SUBROUTINE fexchem                                                       
                                                                                
  END MODULE mod_chem_spack_fexchem                                             
                                                                                
